package com.gupaoedu.rpc;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class Proxyhandler implements InvocationHandler {
    private final NetTransport netTransport;

    public Proxyhandler(String host, int port) {
        this.netTransport = new NetTransport(host, port);
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        RpcRquest rpcRquest = new RpcRquest(method.getDeclaringClass().getName(), method.getName(), args);
        return netTransport.send(rpcRquest);
    }
}
